package edu.ncsu.contractminer.utilities;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;

public class Dictionaries {

	private static Dictionaries instance = null;
	private static HashSet<String> stopWordSet = new HashSet<String>();

	private Dictionaries() {
		try {
			FileReader fr = new FileReader(Constants.englishStopWordFile);
			BufferedReader br = new BufferedReader(fr);
			String line = "";
			while ((line = br.readLine()) != null) {
				stopWordSet.add(line.trim().toLowerCase());
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public static synchronized Dictionaries getInstance() {
		if (instance == null) {
			instance = new Dictionaries();
		}
		return instance;
	}

	public static HashSet<String> getStopWordSet() {
		return stopWordSet;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Dictionaries d = Dictionaries.getInstance();
		System.out.println(d.getStopWordSet());

	}

}
